#ifndef  __MC_SINGLESHUNT_H
#define  __MC_SINGLESHUNT_H

#include "MC_PMSM_Driver.h"



#ifndef	 	PWMBASEFERQUE
#define  	PWMBASEFERQUE					64000000
#endif
#ifndef	 	PWMFREQUE
#define	 	PWMFREQUE						16000
#endif
#ifndef	 	PWMPERIOD
#define	 	PWMPERIOD						(PWMBASEFERQUE/PWMFREQUE)/2				
#endif

#define		CALFULLDUTY						32768											//Q15
#define		PWMPERIOD_QUAD					PWMPERIOD/4
#define		PWMTIMEBASE						PWMBASEFERQUE/1000000
#define		ADCCONVERTIME					PWMTIMEBASE*3									//adc convert time is 3us
#define		DCBUSSETTIME					PWMTIMEBASE*1.2									//dc bus settime is 1us	
#define		DEVEDEADTIME					PWMTIMEBASE*1.4									//power device deadtime is 0.7*2us

#define		TSAM_MIN						(64*3)
#define		TSAM_MINDOU						TSAM_MIN*2
#define		TSAM_HALF						TSAM_MIN/2
#define		TSAM_QUAD						TSAM_HALF/2
#define		TSAM_EITH						TSAM_QUAD/2
#define		TSAM_DELAY						0

typedef struct
{
 s32 Areaphase;
 s32 Breaphase;
 s32 Creaphase;
}Rephasecurr_Component_t;
extern Rephasecurr_Component_t		reaconcurrent;

typedef struct
{
 s16  pwmsm0_shift;
 s16  pwmsm1_shift;
 s16  pwmsm2_shift;
 s16  pwmsm32_shift;
 s16  pwmsm33_shift; 
 s16  pwmtsm0_shift;
 s16  pwmtsm1_shift;
 s16  pwmtsm2_shift;
 s16  pwmtsm32_shift;
 s16  pwmtsm33_shift; 
} pwmshift_values;

typedef struct
{
  s32 t1_duty;
  s32 t2_duty;
}Valvectorduty;

typedef struct
{
  u16 t1_clock;
  u16 t2_clock;
  u16 zero_clock;
}Valpwmclock;

typedef struct
{
 s16	delay_one;
 s16	delay_two;
}Singleshuntdelay;


typedef	struct
{
  u8 delayonebit;
  u8 delaytwobit;
}Phaseshiftbit;

typedef	struct
{
 s32	Aphasebase;
 s32	Bphasebase;
 s32	Cphasebase;
 s32	Aphaseupval;
 s32	Bphaseupval;
 s32	Cphaseupval;
 s32	Aphasednval;
 s32	Bphasednval;
 s32	Cphasednval;
	
 u32	AdnPWMCmpdat;
 u32	BdnPWMCmpdat;	
 u32	CdnPWMCmpdat;	
 u8 	SampleChenal;
	
}Pwmreisterval;

extern Valvectorduty		            valdduty;
extern Pwmreisterval					singleshuntpwmval;
extern u8								u8_pwmtriadcswitch;
extern void  							f_ADCdelay_Component(void);
extern void  							MC_PWM_TG(void);
extern void  							MC_GET_CURR(void);
extern void  							MC_SINGLESHUNT(SVM_Components *Svmcompentpointer);


#endif


